package com.ozo.cloud.common.satoken.config;

import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.stp.StpInterface;
import com.ozo.cloud.common.satoken.permission.SaPermissionImpl;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Sa-Token 权限认证 配置类
 *
 * @author qiangesoft
 * @date 2024-09-10
 */
@AutoConfiguration
public class SaTokenConfiguration implements WebMvcConfigurer {

    /**
     * 注解鉴权拦截器、用户拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new SaInterceptor()).addPathPatterns("/**");
    }

    @Bean
    public StpInterface stpInterface() {
        return new SaPermissionImpl();
    }

}
